import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router";

import Layout from "@/layout/index.vue";

import { MyRoutesTy } from "~/router.d"


let routes: MyRoutesTy = [
    {
        path: "/",
        hidden: true,
        redirect: "/home"
    },
    {
        path: "/login",
        hidden: true,
        component: () => import("@/views/login/index.vue")
    },
    {
        path: "/home",
        component: Layout,
        hidden: false,
        meta: {
            title: "首页",
            icon: "data"
        },
        children: [
            {
                path: "/home",
                component: () => import("@/views/home/index.vue")
            }
        ]
    },
    {
        // /user/profile
        path: "/user",
        component: Layout,
        hidden: false,
        meta: {
            title: "用户管理",
            icon: "user",
            path: "/user/list"
        },
        redirect: "/user/list",
        children: [
            {
                path: "/user/list",
                meta: {
                    title: "用户列表",
                    path: "/user/list"
                },
                component: () => import("@/views/user/user-list.vue")
            },
            {
                path: "/user/add",
                meta: {
                    title: "用户添加",
                    path: "/user/add"
                },
                component: () => import("@/views/user/user-add.vue")
            },
            {
                path: "/user/profile",
                meta: {
                    title: "用户中心",
                    path: "/user/profile"
                },
                component: () => import("@/views/user/user-profile.vue")
            }
        ]
    },
    {
        path: "/article",
        component: Layout,
        hidden: false,
        meta: {
            title: "文章列表",
            icon: "article",
            path: "/article/list"
        },
        redirect: "/article/list",
        children: [
            {
                path: "/article/list",
                component: () => import("@/views/article/article-list.vue")
            },
            {
                path: "/article/edit",
                component: () => import("@/views/article/article-edit.vue")
            }
        ]
    },
    {
        path: "/excel",
        component: Layout,
        hidden: false,
        meta: {
            title: "excel管理",
            icon: "excel",
            path: "/excel/import"
        },
        redirect: "/excel/import",
        children: [
            {
                path: "/excel/import",
                meta: {
                    title: "excel导入",
                    path: "/excel/import"
                },
                component: () => import("@/views/excel/excel-import.vue")
            },
            {
                path: "/excel/export",
                meta: {
                    title: "excel导出",
                    path: "/excel/export"
                },
                component: () => import("@/views/excel/excel-export.vue")
            },
        ]
    }
]


let router = createRouter({
    routes,
    history: createWebHashHistory()
})


export default router